package com.jp.knowledge.my.activity;

import android.content.Intent;
import android.view.View;

import com.google.gson.JsonObject;
import com.jp.knowledge.R;
import com.jp.knowledge.http.HttpHelper;
import com.jp.knowledge.my.resources.OrganizeJoinRes;

public class ClassActivity extends DepartmentActivity {

    @Override
    protected void init() {
        super.init();
        topName.setText("选择班级");
        findViewById(R.id.department_btn_create).setVisibility(View.VISIBLE);
    }

    @Override
    public void itemSelect(int position) {
        Intent intent = getIntent();
        intent.putExtra(OrganizeJoinRes.RESPONSE_RESULT, adapter.getData(position).getName());
        intent.putExtra(OrganizeJoinRes.CLASS_ID, adapter.getData(position).getId());;
        setResult(RESULT_OK, intent);
//        finish();
        intent.setClass(this, OptionSchoolTimeActivity.class);
        startActivity(intent);
    }

    protected void getData(){
        JsonObject param = new JsonObject();
        param.addProperty("token", HttpHelper.token);
        param.addProperty("id", getIntent().getStringExtra(OrganizeJoinRes.ID));
        param.addProperty("depaId", getIntent().getStringExtra(OrganizeJoinRes.DEPA_ID));
        HttpHelper.getInstance(this).getClass(param, requestCode, this);
    }

    @Override
    protected void createBnClick() {
        Intent intent = getIntent();
        intent.setClass(this, DepartmentCreateActivity.class);
        intent.putExtra(OrganizeJoinRes.TITLE_CREATE, getString(R.string.create_class_title));
        intent.putExtra(OrganizeJoinRes.REMIND_CREATE, getString(R.string.create_class_remind));
        startActivityForResult(intent, requestCode);
    }
}
